<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var date1 = new Date();
    
    //获取年份
    var year = date1.getFullYear();
    console.log(year);

    //获取月份取值0~11
    var month = date1.getMonth();
    console.log(month);
    month = month+1
    console.log(month);

    //***获取星期几
    //获取星期的范围0~6
    //每个星期的第一天是星期日
    var weekday = date1.getDay();
    console.log(weekday);
    var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
    var weekday = date1.getDay();
    console.log(weeks[weekday]);

    //获取日
    var day = date1.getDate();
    console.log(day);

    //获取时，分，秒
    var hour = date1.getHours();
    var minute = date1.getMinutes();
    var second = date1.getSeconds();
    console.log(hour + ":" + minute + ":"+ second);
</script>
</html>